import json

from flask import Blueprint, jsonify, request
from flask_login import logout_user, login_user
import  application.models as Models

auth_bp = Blueprint('auth', __name__, url_prefix='/auth')

# @auth_bp.route('/login', methods=['POST'])
# def login():
#     info = json.loads(request.data)
#     username = info.get('username', 'guest')
#     password = info.get('password', '')
#
#     user = Models.User.objects(name=username,
#                                password=password).first()
#     if user:
#         login_user(user)
#         return jsonify(user.to_json())
#     else:
#         return jsonify({"status": 401,
#                         "reason": "Username or Password Error"})
#
#
# @auth_bp.route('/logout', methods=['POST'])
# def logout():
#     logout_user()
#     return jsonify(**{'result': 200,
#                       'data': {'message': 'logout success'}})
